package com.yixin.mapper;

import com.yixin.entity.Emp;
import com.yixin.entity.EmpQueryParam;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface EmpMapper {

    List<Emp> findPage(EmpQueryParam param);

    @Insert("insert into emp(name, password, phone, gender, dept_id, is_del, create_time, update_time) values(#{name}, #{password}, #{phone}, #{gender}, #{deptId}, #{isDel}, #{createTime}, #{updateTime})")
    void add(Emp emp);

    @Update("update emp set name = #{name}, password = #{password}, phone = #{phone}, gender = #{gender}, dept_id = #{deptId}, update_time = #{updateTime} where id = #{id}")
    void update(Emp emp);

    void deleteById(List<Integer> ids);

    @Select("select id, name, phone from emp where phone = #{phone} and password = #{password}")
    Emp selectByPhoneAndPwd(Emp emp);
}
